package com.ruoyi.develop.factory.factoryGongyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.develop.factory.factoryGongyi.domain.FactoryGongyi;
import com.ruoyi.develop.factory.factoryGongyi.service.IFactoryGongyiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 检验工艺Controller
 * @author qh
 * @date 2024-11-06
 */
@RestController
@RequestMapping("/factoryGongyi/factoryGongyi")
public class FactoryGongyiController extends BaseController {
    @Autowired
    private IFactoryGongyiService factoryGongyiService;

    /**
     * 查询检验工艺列表
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryGongyi:query')")
    @GetMapping("/list")
    public TableDataInfo list(FactoryGongyi entity) {
        startPage();
        List<FactoryGongyi> list = factoryGongyiService.selectList(entity);
        return getDataTable(list);
    }

    /**
     * 导出检验工艺列表
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryGongyi:export')")
    @Log(title = "检验工艺", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FactoryGongyi entity) {
        List<FactoryGongyi> list = factoryGongyiService.selectList(entity);
        ExcelUtil<FactoryGongyi> util = new ExcelUtil<FactoryGongyi>(FactoryGongyi. class);
        util.exportExcel(response, list, "检验工艺数据");
    }

    /**
     * 获取检验工艺详细信息
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryGongyi:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(factoryGongyiService.selectById(id));
    }

    /**
     * 新增检验工艺
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryGongyi:add')")
    @Log(title = "检验工艺", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody FactoryGongyi entity) {
        return toAjax(factoryGongyiService.insert(entity));
    }

    /**
     * 修改检验工艺
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryGongyi:edit')")
    @Log(title = "检验工艺", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody FactoryGongyi entity) {
        return toAjax(factoryGongyiService.update(entity));
    }

    /**
     * 删除检验工艺
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryGongyi:remove')")
    @Log(title = "检验工艺", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(factoryGongyiService.deleteByIds(ids));
    }
}
